package com.colorlight.cloud.mqtt.base.entity;

import lombok.Builder;
import lombok.Data;

import java.util.Set;

/**
 * @author Demon
 * broker 服务器地址
 */
@Data
@Builder
public class ConnectDetail {
	private String brokerUrl;
	private String clientId;
	private String username;
	private String password;
	private Set<TopicDetail> topicDetails;
	
	ConnectDetail(String brokerUrl,
	              String clientId,
	              String username,
	              String password,
	              Set<TopicDetail> topicDetails) {
		if (brokerUrl == null || brokerUrl.isEmpty()) {
			throw new NullPointerException("brokerUrl can be not null");
		}
		if (clientId == null || clientId.isEmpty()) {
			throw new NullPointerException("clientId can be not null");
		}
		if (username == null || username.isEmpty()) {
			throw new NullPointerException("username can be not null");
		}
		if (password == null || password.isEmpty()) {
			throw new NullPointerException("password can be not null");
		}
		if (topicDetails == null || topicDetails.size() == 0) {
			throw new NullPointerException("topicDetails can be not null");
		}
		this.brokerUrl = brokerUrl;
		this.clientId = clientId;
		this.username = username;
		this.password = password;
		this.topicDetails = topicDetails;
	}
}
